package com.quectel.constant.core.scheduling;

import com.quectel.constant.global.SystemConstants;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author zhangheng
 * @email nolan.zhang@quectel.com
 * @date 2023/7/5 13:52
 * @description 考勤审核常量类
 */
public class SchedulingApplyConstants {



    /*
        CMS 查询参数
     */
    /*************** cms查询参数开始 ***************/
    public static final String LEAVE_TYPE = "leaveType";
    public static final String APPLY_STATUS = "applyStatus";
    public static final String DEPT_PERSON_NAME = "deptPersonName";
    public static final String CREATE_TIME_START = "createTimeStart";
    public static final String CREATE_TIME_END = "createTimeEnd";
    /**
     * 审核中
     */
    public static final String CMS_AUDITING = "0";
    /**
     * 已同意
     */
    public static final String CMS_APPROVED = "1";
    /**
     * 已拒绝
     */
    public static final String CMS_REJECTED = "2";
    /**
     * 已拒绝
     */
    public static final String CMS_WRITE_OFF_STATUS = "3";


    /*************** cms查询参数结束 ***************/

    /**
     * 当前节点标识
     */
    public static final String IS_CURRENT = "isCurrent";

    /**
     * 已审核标识
     */
    public static final String IS_AUDITED = "isAudited";
    /**
     * 审批中
     */
    public static final String AUDITING = "1";
    /**
     * 已完成
     */
    public static final String FINISHED = "2";

    /**
     * 草稿
     */
    public static final String NOT_SUBMITTED = "3";


    /**
     * 接受的文件类型
     * 图片 image/png,image/jpeg,image/bmp
     * 文档
     * xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
     * pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
     * docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
     * ppt application/vnd.ms-powerpoint
     * xls application/vnd.ms-excel
     * doc application/msword
     * <p>
     * PDF
     * pdf application/pdf
     */
    public static final Set<String> FILE_ACCEPT_TYPE = new HashSet<>(Arrays.asList(
            "image/png"
            , "image/jpeg"
            , "image/bmp"
            , "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            , "application/vnd.openxmlformats-officedocument.presentationml.presentation"
            , "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            , "application/vnd.ms-powerpoint"
            , "application/vnd.ms-excel"
            , "application/msword"
            , "application/pdf"
    ));


    /**
     * -3未提交(草稿) -2已关闭 -1已取消 0待审核 1通过 2驳回 3核销(销假申请后原审核记录的状态)
     */
    public static final Byte NOT_SUBMITTED_STATUS = -3, CLOSE_STATUS = -2, CANCEL_STATUS = -1, INIT_STATUS = 0, APPROVED_STATUS = 1, REJECT_STATUS = 2, WRITE_OFF_STATUS = 3;
    /**
     * -1关闭序列 1审批序列开始
     */
    public static final Integer CURRENT_AT_SEQ_OF_CLOSE = -1, CURRENT_AT_SEQ_OF_CREATOR = 0, CURRENT_AT_SEQ_OF_BEGIN = 1;

    /**
     * 正在审核的状态
     */
    public static final Byte[] AUDITING_STATUSES = {
            SchedulingApplyConstants.INIT_STATUS
    };
    /**
     * 已审核的状态
     */
    public static final Byte[] FINISHED_STATUSES = {
            SchedulingApplyConstants.CLOSE_STATUS,
            SchedulingApplyConstants.CANCEL_STATUS,
            SchedulingApplyConstants.APPROVED_STATUS,
            SchedulingApplyConstants.REJECT_STATUS,
            SchedulingApplyConstants.WRITE_OFF_STATUS
    };

    /**
     * 审核查询已审核状态
     */
    public static final Byte[] AUDIT_FINISHED_STATUSES = {
            SchedulingApplyConstants.CLOSE_STATUS,
            SchedulingApplyConstants.CANCEL_STATUS,
            SchedulingApplyConstants.INIT_STATUS,
            SchedulingApplyConstants.APPROVED_STATUS,
            SchedulingApplyConstants.REJECT_STATUS,
            SchedulingApplyConstants.WRITE_OFF_STATUS
    };
    /**
     * 草稿状态
     */
    public static final Byte[] NOT_SUBMITTED_STATUSES_STATUSES = {
            SchedulingApplyConstants.NOT_SUBMITTED_STATUS
    };


    /**
     * 余额增加或者扣减类型
     */
    @AllArgsConstructor
    public enum BalanceTypeEnum {
        /**
         * 请假 发放是在总额上 是增加
         */
        AUTO_GRANT((byte) 1, "自动发放", SystemConstants.YES),
        /**
         * 申请扣减 扣减是在usedBalance上 是增加
         */
        APPLY((byte) 2, "申请扣减",SystemConstants.YES),

        /**
         * 考勤记录回收 是在usedBalance上 是减少
         */
        DAILY_CAL_UPDATE((byte) 3, "考勤记录回收",SystemConstants.NO),

        /**
         * 加班转余额 是在总额上 是增加
         */
        OVERTIME_CONVERTED_TO_BALANCE((byte) 4, "加班转余额",SystemConstants.YES),


        ;
        @Getter
        private final Byte type;
        @Getter
        private final String desc;
        /**
         * 增加或者减少的标识
         */
        @Getter
        private final Byte isPositive;

        public static BalanceTypeEnum getByType(Byte type) {
            for (BalanceTypeEnum typeEnum : BalanceTypeEnum.values()) {
                if (typeEnum.getType().equals(type)) {
                    return typeEnum;
                }
            }
            return null;
        }
    }

    /**
     * 审核类型
     */
    @AllArgsConstructor
    public enum ApplyTypeEnum {
        /**
         * 请假
         */
        APPLY_LEAVE((byte) 1, "请假"),
        /**
         * 销假
         */
        RESUMPTION_LEAVE((byte) 2, "销假"),

        /**
         * 补卡
         */
        RENEW_CARD((byte) 3, "补卡"),

        /**
         * 出差
         */
        TRIP((byte) 4, "出差"),

        /**
         * 外出
         */
        OUT((byte) 5, "外出"),

        /**
         * 加班
         */
        OVER_TIME((byte) 6, "加班"),

        /**
         * 调班
         */
        TRANSFER_CLASS((byte) 7, "调班"),
        ;
        @Getter
        private final Byte type;
        @Getter
        private final String desc;

        public static ApplyTypeEnum getByType(Byte type) {
            for (ApplyTypeEnum typeEnum : ApplyTypeEnum.values()) {
                if (typeEnum.getType().equals(type)) {
                    return typeEnum;
                }
            }
            return null;
        }
    }

    /**
     * 审核类型
     */
    @AllArgsConstructor
    public enum TransferClassTypeEnum {
        /**
         * 与其他人换班
         */
        OTHER((byte) 1),
        /**
         * 与自己换班
         */
        MYSELF((byte) 2),


        ;
        @Getter
        private final Byte type;

    }


}
